package mypackage.maptest;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapTest1 {

    public static void main(String[] args) {

        Map<String, String> outputs = new HashMap<>();
        outputs.put("a", "/ProjectData/.dataset/a");
        outputs.put("b", "/ProjectData/.dataset/b");
        outputs.put("c", "/ProjectData/.dataset/c");
        outputs.put("d", "/ProjectData/only/.dataset/d");

        outputs.put("2D相似度搜索结果", "/ProjectData/file/.dataset/2D相似度搜索结果");
        outputs.put("test66", "/ProjectData/.dataset/test66");

        Map<String, String> resultOutputs = processOutputs(outputs);
        System.out.println("resultOutputs = " + resultOutputs);
    }

    private static Map<String, String> processOutputs(Map<String, String> outputs) {
        Map<String, String> result = new HashMap<>();
        Set<String> keySet = outputs.keySet();
        for (String key : keySet) {
            String output = outputs.get(key);
            String resultOutput = null;
            if (output.contains(".dataset")) {
                resultOutput = output.substring(0, output.indexOf(".dataset") - 1);
                result.put(key, resultOutput);
            }else {
                result.put(key, output);
            }

        }
        return result;
    }
}
